Skip to content

Conversation

@nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Mar 16, 2025

User description

Motivation and Context

Contributes to #15407

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Refactored PartitionDescriptor to avoid nested DTO types.

  • Introduced ContextPartitionDescriptor and StorageKeyPartitionDescriptor.

  • Updated usages of PartitionDescriptor.Context to ContextPartitionDescriptor.

  • Improved code clarity and future extensibility by removing nested types.


Changes walkthrough 📝

Relevant files
Enhancement
BrowsingContextStorageModule.cs
Updated `PartitionDescriptor` usage in BrowsingContext module

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextStorageModule.cs

  • Replaced PartitionDescriptor.Context with ContextPartitionDescriptor.
  • Updated method implementations to use the new descriptor.
  • +3/-3     
    GetCookiesCommand.cs
    Refactored `PartitionDescriptor` and added new descriptors

    dotnet/src/webdriver/BiDi/Modules/Storage/GetCookiesCommand.cs

  • Refactored PartitionDescriptor to remove nested types.
  • Added ContextPartitionDescriptor and StorageKeyPartitionDescriptor.
  • Updated JSON polymorphic annotations for new descriptors.
  • +9/-10   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @qodo-merge-pro
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    15407 - PR Code Verified

    Compliant requirements:

    • Replace nested DTO types with standalone types
    • Move from pattern like new Locator.Css("div") to new CssLocator("div")
    • Avoid nested types that reserve names in parent classes

    Requires further human verification:

    • Verify if all nested DTO types in the codebase have been identified and refactored, as the PR only shows changes for PartitionDescriptor

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Missing Constructor

    The StorageKeyPartitionDescriptor class is missing a constructor that matches the pattern established by ContextPartitionDescriptor. This inconsistency could lead to usage issues.

    public record StorageKeyPartitionDescriptor : PartitionDescriptor
    {
        public string? UserContext { get; set; }
    
        public string? SourceOrigin { get; set; }
    }

    @qodo-merge-pro
    Copy link
    Contributor

    qodo-merge-pro bot commented Mar 16, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Ensure consistent async pattern

    The method doesn't use await but returns the Task directly. Since the method
    signature is Task and not async Task, this is correct, but inconsistent with the
    other methods in the class that use async/await pattern. Consider making this
    method consistent with the others by using async/await.

    dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextStorageModule.cs [27-34]

    -public Task<GetCookiesResult> GetCookiesAsync(GetCookiesOptions? options = null)
    +public async Task<GetCookiesResult> GetCookiesAsync(GetCookiesOptions? options = null)
     {
         options ??= new();
     
         options.Partition = new ContextPartitionDescriptor(context);
     
    -    return storageModule.GetCookiesAsync(options);
    +    return await storageModule.GetCookiesAsync(options).ConfigureAwait(false);
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly identifies an inconsistency in the async pattern usage across methods in the class. Making the GetCookiesAsync method use the async/await pattern with ConfigureAwait(false) would improve code consistency and maintainability, though it doesn't fix a functional bug.

    Low
    • Update

    @nvborisenko nvborisenko merged commit d260b33 into SeleniumHQ:trunk Mar 17, 2025
    9 of 10 checks passed
    @nvborisenko nvborisenko deleted the bidi-partitiondescriptor branch March 17, 2025 15:20
    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Mar 23, 2025
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants